<template>
 
  <div class="sales-add">
     <h1>修改账号</h1>
    <el-form ref="form" :model="form" label-width="100px">
     
      <el-form-item label="管理员用户名">
        <el-input v-model="form.username"></el-input>
      </el-form-item>
       <el-form-item label="管理员密码">
        <el-input v-model="form.password"></el-input>
      </el-form-item>
     <el-form-item label="权限" >
    <el-radio-group v-model="form.permission">
      <el-radio label="1" >管理员</el-radio>
      <el-radio label="9" >超级管理员</el-radio>
    </el-radio-group>
  </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="updateAdmin(form)">修改</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import {createNamespacedHelpers} from "vuex"
const {mapState,mapActions}=createNamespacedHelpers('admin')
export default {
  data(){
    return {
      form:{
        _id:"",
        username:	"",
        password:"",
        permission:"",
      },
      DataById:{
        data:[]
      }
      
    }
  },
  computed:{
       
    
  },
   created(){
   var _this=this;
  async function getImg(){
	_this.DataById.data=await _this.getAdminById(_this.$route.query._id)
  _this.form.username=_this.DataById.data[0].username
    _this.form._id=_this.DataById.data[0]._id
  _this.form.password=_this.DataById.data[0].password
  _this.form.permission=_this.DataById.data[0].permission
	  }
  getImg()
   },
 
   
  methods:{

      ...mapActions(['getAdminById',"updateAdmin"]),
      
     
   
  },
}
</script>

<style>
  .sales-add {
  width: 400px;
  margin: 20px auto;
}
.avatar-uploader .el-upload {
    border: 1px dashed #ffffff;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    background-color: #ffffff;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #ddd9d9;
    width: 100px;
    height: 100px;
    line-height: 100px;
    text-align: center;
  }
  .avatar {
    width: 100px;
    height: 100px;
    display: block;
  }
</style>